home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************\
-
- File: my mdef.c
-
- Purpose: This module handles an MDEF for an on-the-fly Sierpinski's
- Gasket.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program in a file named "GNU General Public License".
- If not, write to the Free Software Foundation, 675 Mass Ave,
- Cambridge, MA 02139, USA.
-
- \**********************************************************************/
-
- /* compile as code resource, type 'MDEF', ID 1234, attributes = 0x00 */
- /* no custom header, file type 'rsrc', creator 'RSED' */
- /* compile & merge into project .rsrc file */
- /* set MDEF ID of the menu to 1234 with Resedit */
-
- #include "SetUpA4.h"
-
- #define MENU_WIDTH 256
- #define MENU_HEIGHT 222
-
- pascal void main(short message, MenuHandle theMenu, Rect *r, Point hitPt, short *which);
-
- short curX=0;
- short curY=0;
-
- pascal void main(short message, MenuHandle theMenu, Rect *r, Point hitPt, short *which)
- {
- Point pt;
- short whichVertex;
- short newX, newY;
-
- RememberA0();
- SetUpA4();
- switch (message)
- {
- case 0:
- /* draw the menu */
- EraseRect(r);
- break;
- case 1:
- /* choose and hilight */
- whichVertex=(Random()&0x7fff)%3;
- switch (whichVertex)
- {
- case 0: SetPt(&pt, MENU_WIDTH/2, 0); break;
- case 1: SetPt(&pt, 0, MENU_HEIGHT); break;
- case 2: SetPt(&pt, MENU_WIDTH, MENU_HEIGHT); break;
- }
- newX=((pt.h)+curX)/2;
- newY=((pt.v)+curY)/2;
- MoveTo(r->left+newX, r->top+newY);
- Line(0,0);
- curX=newX;
- curY=newY;
- break;
- case 2:
- /* calculate size */
- (**theMenu).menuWidth = MENU_WIDTH;
- (**theMenu).menuHeight = MENU_HEIGHT;
- curX=MENU_WIDTH/2;
- curY=0;
- break;
- }
- RestoreA4();
- }
-